base: preserve color in premutiplied alpha
authorØyvind Kolås <pippin@gimp.org>
Fri, 24 Aug 2018 17:16:34 +0000 (19:16 +0200)
committerØyvind Kolås <pippin@gimp.org>
Fri, 24 Aug 2018 23:18:25 +0000 (01:18 +0200)
commit97008a219a1f3f96416d4d7c78b3482b8840c838
tree11d38cb038d5a4fbac64626b4ee5d9c12cf45bc5
parentc153fec67e0eb15d8ca15d5f019d239c01e0c12b
base: preserve color in premutiplied alpha

Alpha values below BABL_ALPHA_FLOOR gets stored in the components
as BABL_ALPHA_FLOOR with alpha also set to BABL_ALPHA_FLOOR,
recovery from pre-multiplied to non-premultiplied is done as normal.
BABL_FLOOR is set to be 1/65536.0 with a hope that this gives us
approximately 8bit of color data preserved when using half-float.

Upon encountering exactly BABL_ALPHA_FLOOR in premultiplied conversion
to non-premultiplied interprets this as 0.0, making pure 0.0 values
round trip correctly from RGBA to RaGaBaA back to RGBA.

This makes a lot of extensions invalid - as expected but it already
allows testing the behavior of GEGL and GIMP with this additional
feature from babl.
babl/babl-internal.h
babl/base/babl-base.h
babl/base/model-gray.c
babl/base/model-rgb.c
babl/base/util.h